package com.wang.ymcc.service.impl;


import com.wang.lwm.util.StrUtils;
import com.wang.ymcc.service.ITokenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

@Service
public class TokenServiceImpl implements ITokenService {

    @Autowired
    private RedisTemplate<Object,Object> template;

    @Override
    public String createOrderToken(String ids) {
        //1.生成一个token-uuid ， 验证码工具生成
        String token = StrUtils.getComplexRandomString(10);
        //2.存放到redis里面
        /*
            token:token

            当前的登录人+购买的商品
            3:9 --- 1234165
            3:8 --- 1654+649684

         */
        //1.获取当前登录用户
        Long loginId =3L;
        template.opsForValue().set(loginId+":"+ids,token);
        return token;
    }
}
